package com.wmx.java_8.CompletableFuture;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.function.Consumer;
import java.util.function.Supplier;

/**********************************
 * @author wmx
 * @date 2019/10/15 14:55
 * @description:
 * @version 1.0
 ************************************/
public class CompletableFutureDemo {

    public static void main(String[] args) {
        ExecutorService executorService = Executors.newFixedThreadPool(1);
        CompletableFuture.supplyAsync(()->{return 10;},executorService).thenAccept(a->{
            for (int i = 0; i < a ; i++) {
                System.out.println(Thread.currentThread().getName());
                System.out.println(i);
            }
        });

        executorService.shutdown();
    }
}